<!doctype html>
<html itemscope itemtype="http://schema.org/WebPage" lang="zh-cn" class="no-js">
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="generator" content="Hugo 0.121.1">
<meta name="robots" content="index, follow">


<link rel="shortcut icon" href="/favicons/favicon.ico" >
<link rel="apple-touch-icon" href="/favicons/apple-touch-icon-180x180.png" sizes="180x180">
<link rel="icon" type="image/png" href="/favicons/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicons/android-36x36.png" sizes="36x36">
<link rel="icon" type="image/png" href="/favicons/android-48x48.png" sizes="48x48">
<link rel="icon" type="image/png" href="/favicons/android-72x72.png" sizes="72x72">
<link rel="icon" type="image/png" href="/favicons/android-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/favicons/android-144x144.png" sizes="144x144">
<link rel="icon" type="image/png" href="/favicons/android-192x192.png" sizes="192x192">

<title>架构原理 | SOFAServerless</title>
<meta name="description" content="模块化应用架构 为了解决这些问题，我们对应用同时做了横向和纵向的拆分。首先第一步纵向拆分：把应用拆分成基座和业务两层，这两层分别对应两层的组织分工。基座小组与传统应用一样，负责机器维护、通用逻辑沉淀、业务架构治理，并为业务提供运行资源和环境。通过关注点分离的方式为业务屏蔽业务以下所有基础设施，聚焦在业务自身上。第二部我们将业务进行横向切分出多个模块，多个模块之间独立并行迭代互不影响，同时模块由于不包含基座部分，构建产物非常轻量，启动逻辑也只包含业务本身，所以启动快，具备秒级的验证能力，让模块开发得到极致的提效。
拆分之前，每个开发者可能感知从框架到中间件到业务公共部分到业务自身所有代码和逻辑，拆分后，团队的协作分工也从发生改变，研发人员分工出两种角色，基座和模块开发者，模块开发者不关系资源与容量，享受秒级部署验证能力，聚焦在业务逻辑自身上。
这里要重点看下我们是如何做这些纵向和横向切分的，切分是为了隔离，隔离是为了能够独立迭代、剥离不必要的依赖，然而如果只是隔离是没有共享相当于只是换了个部署的位置而已，很难有好的效果。所以我们除了隔离还有共享能力，所以这里需要聚焦在隔离与共享上来理解模块化架构背后的原理。
模块的定义 在这之前先看下这里的模块是什么？模块是通过原来应用减去基座部分得到的，这里的减法是通过设置模块里依赖的 scope 为 provided 实现的，
一个模块可以由这三点定义：
SpringBoot 打包生成的 jar 包 一个模块： 一个 SpringContext &#43; 一个 ClassLoader 热部署（升级的时候不需要启动进程） 模块的隔离与共享 模块通过 ClassLoader 隔离配置和代码，SpringContext 隔离 Bean 和服务，可以通过调用 Spring ApplicationContext 的start close 方法来动态启动和关闭服务。通过 SOFAArk 来共享模块和基座的配置和代码 Class，通过 SpringContext Manager 来共享多模块间的 Bean 和服务。
并且在 JVM 内通过
Ark Container 提供多 ClassLoader 运行环境 Arklet 来管理模块生命周期 Framework Adapter 将 SpringBoot 生命周期与模块生命周期关联起来 SOFAArk 默认委托加载机制，打通模块与基座类委托加载 SpringContext Manager 提供 Bean 与服务发现调用机制 基座本质也是模块，拥有独立的 SpringContext 和 ClassLoader 但是在 Java 领域模块化技术已经发展了20年了，为什么这里的模块化技术能够在蚂蚁内部规模化落地，这里的核心原因是">
<meta property="og:title" content="架构原理" />
<meta property="og:description" content="模块化应用架构 为了解决这些问题，我们对应用同时做了横向和纵向的拆分。首先第一步纵向拆分：把应用拆分成基座和业务两层，这两层分别对应两层的组织分工。基座小组与传统应用一样，负责机器维护、通用逻辑沉淀、业务架构治理，并为业务提供运行资源和环境。通过关注点分离的方式为业务屏蔽业务以下所有基础设施，聚焦在业务自身上。第二部我们将业务进行横向切分出多个模块，多个模块之间独立并行迭代互不影响，同时模块由于不包含基座部分，构建产物非常轻量，启动逻辑也只包含业务本身，所以启动快，具备秒级的验证能力，让模块开发得到极致的提效。
拆分之前，每个开发者可能感知从框架到中间件到业务公共部分到业务自身所有代码和逻辑，拆分后，团队的协作分工也从发生改变，研发人员分工出两种角色，基座和模块开发者，模块开发者不关系资源与容量，享受秒级部署验证能力，聚焦在业务逻辑自身上。
这里要重点看下我们是如何做这些纵向和横向切分的，切分是为了隔离，隔离是为了能够独立迭代、剥离不必要的依赖，然而如果只是隔离是没有共享相当于只是换了个部署的位置而已，很难有好的效果。所以我们除了隔离还有共享能力，所以这里需要聚焦在隔离与共享上来理解模块化架构背后的原理。
模块的定义 在这之前先看下这里的模块是什么？模块是通过原来应用减去基座部分得到的，这里的减法是通过设置模块里依赖的 scope 为 provided 实现的，
一个模块可以由这三点定义：
SpringBoot 打包生成的 jar 包 一个模块： 一个 SpringContext &#43; 一个 ClassLoader 热部署（升级的时候不需要启动进程） 模块的隔离与共享 模块通过 ClassLoader 隔离配置和代码，SpringContext 隔离 Bean 和服务，可以通过调用 Spring ApplicationContext 的start close 方法来动态启动和关闭服务。通过 SOFAArk 来共享模块和基座的配置和代码 Class，通过 SpringContext Manager 来共享多模块间的 Bean 和服务。
并且在 JVM 内通过
Ark Container 提供多 ClassLoader 运行环境 Arklet 来管理模块生命周期 Framework Adapter 将 SpringBoot 生命周期与模块生命周期关联起来 SOFAArk 默认委托加载机制，打通模块与基座类委托加载 SpringContext Manager 提供 Bean 与服务发现调用机制 基座本质也是模块，拥有独立的 SpringContext 和 ClassLoader 但是在 Java 领域模块化技术已经发展了20年了，为什么这里的模块化技术能够在蚂蚁内部规模化落地，这里的核心原因是" />
<meta property="og:type" content="article" />
<meta property="og:url" content="/docs/introduction/architecture/arch-principle/" /><meta property="article:section" content="docs" />

<meta property="article:modified_time" content="2023-10-26T18:06:20+08:00" />

<meta itemprop="name" content="架构原理">
<meta itemprop="description" content="模块化应用架构 为了解决这些问题，我们对应用同时做了横向和纵向的拆分。首先第一步纵向拆分：把应用拆分成基座和业务两层，这两层分别对应两层的组织分工。基座小组与传统应用一样，负责机器维护、通用逻辑沉淀、业务架构治理，并为业务提供运行资源和环境。通过关注点分离的方式为业务屏蔽业务以下所有基础设施，聚焦在业务自身上。第二部我们将业务进行横向切分出多个模块，多个模块之间独立并行迭代互不影响，同时模块由于不包含基座部分，构建产物非常轻量，启动逻辑也只包含业务本身，所以启动快，具备秒级的验证能力，让模块开发得到极致的提效。
拆分之前，每个开发者可能感知从框架到中间件到业务公共部分到业务自身所有代码和逻辑，拆分后，团队的协作分工也从发生改变，研发人员分工出两种角色，基座和模块开发者，模块开发者不关系资源与容量，享受秒级部署验证能力，聚焦在业务逻辑自身上。
这里要重点看下我们是如何做这些纵向和横向切分的，切分是为了隔离，隔离是为了能够独立迭代、剥离不必要的依赖，然而如果只是隔离是没有共享相当于只是换了个部署的位置而已，很难有好的效果。所以我们除了隔离还有共享能力，所以这里需要聚焦在隔离与共享上来理解模块化架构背后的原理。
模块的定义 在这之前先看下这里的模块是什么？模块是通过原来应用减去基座部分得到的，这里的减法是通过设置模块里依赖的 scope 为 provided 实现的，
一个模块可以由这三点定义：
SpringBoot 打包生成的 jar 包 一个模块： 一个 SpringContext &#43; 一个 ClassLoader 热部署（升级的时候不需要启动进程） 模块的隔离与共享 模块通过 ClassLoader 隔离配置和代码，SpringContext 隔离 Bean 和服务，可以通过调用 Spring ApplicationContext 的start close 方法来动态启动和关闭服务。通过 SOFAArk 来共享模块和基座的配置和代码 Class，通过 SpringContext Manager 来共享多模块间的 Bean 和服务。
并且在 JVM 内通过
Ark Container 提供多 ClassLoader 运行环境 Arklet 来管理模块生命周期 Framework Adapter 将 SpringBoot 生命周期与模块生命周期关联起来 SOFAArk 默认委托加载机制，打通模块与基座类委托加载 SpringContext Manager 提供 Bean 与服务发现调用机制 基座本质也是模块，拥有独立的 SpringContext 和 ClassLoader 但是在 Java 领域模块化技术已经发展了20年了，为什么这里的模块化技术能够在蚂蚁内部规模化落地，这里的核心原因是">
<meta itemprop="dateModified" content="2023-10-26T18:06:20+08:00" />
<meta itemprop="wordCount" content="160">
<meta itemprop="keywords" content="" /><meta name="twitter:card" content="summary"/><meta name="twitter:title" content="架构原理"/>
<meta name="twitter:description" content="模块化应用架构 为了解决这些问题，我们对应用同时做了横向和纵向的拆分。首先第一步纵向拆分：把应用拆分成基座和业务两层，这两层分别对应两层的组织分工。基座小组与传统应用一样，负责机器维护、通用逻辑沉淀、业务架构治理，并为业务提供运行资源和环境。通过关注点分离的方式为业务屏蔽业务以下所有基础设施，聚焦在业务自身上。第二部我们将业务进行横向切分出多个模块，多个模块之间独立并行迭代互不影响，同时模块由于不包含基座部分，构建产物非常轻量，启动逻辑也只包含业务本身，所以启动快，具备秒级的验证能力，让模块开发得到极致的提效。
拆分之前，每个开发者可能感知从框架到中间件到业务公共部分到业务自身所有代码和逻辑，拆分后，团队的协作分工也从发生改变，研发人员分工出两种角色，基座和模块开发者，模块开发者不关系资源与容量，享受秒级部署验证能力，聚焦在业务逻辑自身上。
这里要重点看下我们是如何做这些纵向和横向切分的，切分是为了隔离，隔离是为了能够独立迭代、剥离不必要的依赖，然而如果只是隔离是没有共享相当于只是换了个部署的位置而已，很难有好的效果。所以我们除了隔离还有共享能力，所以这里需要聚焦在隔离与共享上来理解模块化架构背后的原理。
模块的定义 在这之前先看下这里的模块是什么？模块是通过原来应用减去基座部分得到的，这里的减法是通过设置模块里依赖的 scope 为 provided 实现的，
一个模块可以由这三点定义：
SpringBoot 打包生成的 jar 包 一个模块： 一个 SpringContext &#43; 一个 ClassLoader 热部署（升级的时候不需要启动进程） 模块的隔离与共享 模块通过 ClassLoader 隔离配置和代码，SpringContext 隔离 Bean 和服务，可以通过调用 Spring ApplicationContext 的start close 方法来动态启动和关闭服务。通过 SOFAArk 来共享模块和基座的配置和代码 Class，通过 SpringContext Manager 来共享多模块间的 Bean 和服务。
并且在 JVM 内通过
Ark Container 提供多 ClassLoader 运行环境 Arklet 来管理模块生命周期 Framework Adapter 将 SpringBoot 生命周期与模块生命周期关联起来 SOFAArk 默认委托加载机制，打通模块与基座类委托加载 SpringContext Manager 提供 Bean 与服务发现调用机制 基座本质也是模块，拥有独立的 SpringContext 和 ClassLoader 但是在 Java 领域模块化技术已经发展了20年了，为什么这里的模块化技术能够在蚂蚁内部规模化落地，这里的核心原因是"/>




<link rel="preload" href="/scss/main.min.526354c4efc1a4747972ed64c3be00f7db62aec5f0a3e6ae42052f97e2675d86.css" as="style">
<link href="/scss/main.min.526354c4efc1a4747972ed64c3be00f7db62aec5f0a3e6ae42052f97e2675d86.css" rel="stylesheet" integrity="">

<script
  src="https://code.jquery.com/jquery-3.6.3.min.js"
  integrity="sha512-STof4xm1wgkfm7heWqFJVn58Hm3EtS31XFaagaa8VMReCXAkQnJZ+jEy8PCC/iT18dFy95WcExNHFTqLyp72eQ=="
  crossorigin="anonymous"></script>
<link rel="stylesheet" href="/css/prism.css"/>
<link href="/img/logo.svg" rel="icon" type="image/svg">
<link href="/search/pagefind-ui.css" rel="stylesheet">
<script src="/search/pagefind-ui.js" type="text/javascript"></script>

<script>
    window.addEventListener('DOMContentLoaded', (event) => {
        new PagefindUI({ element: ".td-search" });
    });
</script>


<script>
var doNotTrack = false;
if (!doNotTrack) {
	window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
	ga('create', 'G-DZ8Q3F0GZ7', 'auto');
	
	ga('send', 'pageview');
}
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>

<script async src="https://www.googletagmanager.com/gtag/js?id=G-DZ8Q3F0GZ7"></script>
<script>
var doNotTrack = false;
if (!doNotTrack) {
	window.dataLayer = window.dataLayer || [];
	function gtag(){dataLayer.push(arguments);}
	gtag('js', new Date());
	gtag('config', 'G-DZ8Q3F0GZ7');
}
</script>
  </head>
  <body class="td-page">
    <header>
      <nav class="td-navbar navbar-dark js-navbar-scroll">
<div class="container-fluid flex-column flex-md-row">
  <a class="navbar-brand" href="/"><span class="navbar-brand__logo navbar-logo"><svg width="26" height="29" viewBox="0 0 26 29" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><linearGradient x1="52.6662558%" y1="95.7312514%" x2="35.7492678%" y2="11.0078657%" id="linearGradient-wxw43fh1xd-1"><stop stop-color="#9822e4" offset="0"/><stop stop-color="#e643fa" offset="86.0585504%"/><stop stop-color="#f876ff" offset="100%"/></linearGradient><path d="M15.9275871 1.54432572 15.936122 1.5594269 15.9445709 1.57457632 5.01248933 7.79418913 7.699 9.304l8.8412359-4.72420311.8668497-.49490764C17.4171462 4.0791454 17.4272394 4.07345885 17.4373647 4.06782987c1.474137-.81952243 3.3335154-.28885241 4.1530379 1.18528466L10.875 11.088l2.864 1.609 8.843271-5.6213813c1.1038914-.6292563 2.5021428-.23250173 3.1230817.88617614C25.8984381 8.30965565 25.9998668 8.70204694 25.9998668 9.10116416V19.9436637c0 1.3476373-1.002317 2.484932-2.3392704 2.6542897L22.9421516 22.6889619V10.4257286L20.457252 12.0257475 20.457758 23.6880152c0 1.2665471-1.0267393 2.2932864-2.2932864 2.2932864H17.59115L17.590252 13.8727475 15.106 15.473 15.1067564 27.0588825c0 1.0695936-.855616100000001 1.9366704-1.911072 1.9366704C12.8696714 28.9955529 12.5490782 28.9110348 12.2643947 28.7500365L1.63270516 23.3171586C.159863707 22.5645249-.423980046 20.7604209.328653641 19.2875794L.372104915 19.2057013 12.0490412 25.0797183 12.049 22.086 1.98952173 16.7675786C.51279311 15.9867912-.0513787599 14.1567129.729408593 12.6799843L.744416289 12.6519572.759717752 12.6240895 12.049 18.593 12.0490412 15.2566254 1.7391964 9.45898637C1.44132502 9.2850324 1.19527431 9.0328708 1.02697438 8.72907568c-.516688418-.93266477-.189466545-2.11320819.7308705-2.63681754C6.19445786 3.56812633 9.52191759 1.67502747 11.7402241.412961569L11.7628911.400065593c1.4660277-.834070345 3.3306257-.321767634 4.164696 1.144260127z" id="path-wxw43fh1xd-2"/><linearGradient x1="50.6099966%" y1="31.6743333%" x2="50.2419846%" y2="73.0702907%" id="linearGradient-wxw43fh1xd-4"><stop stop-color="#8200b5" offset="0"/><stop stop-color="#8200b5" stop-opacity="0" offset="100%"/></linearGradient><linearGradient x1="50.6028666%" y1="31.6743333%" x2="50.2391561%" y2="73.0702907%" id="linearGradient-wxw43fh1xd-5"><stop stop-color="#8200b5" offset="0"/><stop stop-color="#8200b5" stop-opacity="0" offset="100%"/></linearGradient><linearGradient x1="90.8235257%" y1="50%" x2="3.24041867%" y2="52.9415572%" id="linearGradient-wxw43fh1xd-6"><stop stop-color="#dd3ff7" stop-opacity="0" offset="0"/><stop stop-color="#ca23e4" offset="100%"/></linearGradient><linearGradient x1="74.3272776%" y1="35.8586031%" x2="19.6895996%" y2="19.3309621%" id="linearGradient-wxw43fh1xd-7"><stop stop-color="#b800d1" stop-opacity="0" offset="0"/><stop stop-color="#ae00c5" offset="100%"/></linearGradient><linearGradient x1="97.0070676%" y1="71.8003287%" x2="11.3661868%" y2="30.5044309%" id="linearGradient-wxw43fh1xd-8"><stop stop-color="#940ec7" offset="0"/><stop stop-color="#c435f0" stop-opacity="0" offset="100%"/></linearGradient></defs><g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="首页" transform="translate(-24.000000, -18.000000)"><g id="编组-4" transform="translate(24.000133, 16.000000)"><g id="路径-6-copy-2" transform="translate(0.000000, 2.004447)"><mask id="mask-wxw43fh1xd-3" fill="#fff"><use xlink:href="#path-wxw43fh1xd-2"/></mask><use id="Mask" fill="url(#linearGradient-wxw43fh1xd-1)" fill-rule="nonzero" xlink:href="#path-wxw43fh1xd-2"/><path d="M12.0490412 15.2684078 13.03943 15.5167092C14.3279076 16.0478608 15.1686754 17.3038563 15.1686754 18.6975193V18.7421449v9.047164l-3.1196342-1.4070083V15.2684078z" id="Path-114-Copy-2" fill="url(#linearGradient-wxw43fh1xd-4)" opacity=".69047619" mask="url(#mask-wxw43fh1xd-3)"/><path d="M22.9421516 10.4227424 23.8594661 10.2542707C24.8889759 10.219744 25.7876765 10.946368 25.9694916 11.9602841L26.0763097 12.5559692 26.0617858 22.9064645l-3.1196342-1.4070082V10.4227424z" id="Path-114-Copy-2" fill="url(#linearGradient-wxw43fh1xd-5)" opacity=".69047619" mask="url(#mask-wxw43fh1xd-3)"/><polygon id="Path-41" fill="url(#linearGradient-wxw43fh1xd-6)" mask="url(#mask-wxw43fh1xd-3)" points="7.6326499 9.31647968 11.9297751 6.77228295 14.9765833 9.31647968 10.7681311 11.1500753"/><path d="M6.16852974 12.7326226C8.05429918 13.6181711 7.86496926 14.83948 8.18831704 15.006813 8.70089861 15.2720748 9.14143095 17.098905 9.86115602 17.1695013 10.6949216 17.2512836 11.6478081 10.8552079 10.3936906 10.4556578 9.48069361 10.1647855 7.32719679 9.49121213 3.93320016 8.43493769c-.63204609 1.86851711.11306377 3.30107871 2.23532958 4.29768491z" fill="url(#linearGradient-wxw43fh1xd-7)" mask="url(#mask-wxw43fh1xd-3)" transform="translate(7.357416, 12.802608) rotate(-347.000000) translate(-7.357416, -12.802608)"/><polygon id="Path-43" fill="url(#linearGradient-wxw43fh1xd-8)" mask="url(#mask-wxw43fh1xd-3)" points="12.0699788 18.5615749 6.27140769 15.1359473 5.30588708 19.0963147 12.0699788 22.1120507"/></g></g></g></g></svg></span><span class="navbar-brand__name">SOFAServerless</span></a>
  <div class="td-navbar-nav-scroll ms-md-auto" id="main_navbar">
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" href="/home/"><span>首页</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link active" href="/docs/"><span>产品文档</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="/blog/"><span>最新信息</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="/community/"><span>参与社区</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="/user-cases/"><span>用户案例</span></a>
      </li>
      <li class="nav-item dropdown d-none d-lg-block">
        <div class="dropdown">
  <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">中文</a>
  <ul class="dropdown-menu">
    <li><a class="dropdown-item" href="/no/"></a></li>
    </ul>
</div></li>
      </ul>
  </div>
  <div class="d-none d-lg-block">
    <div class="td-search">
  <div class="td-search__icon"></div>
  <input type="search" class="td-search__input form-control td-search-input" placeholder="站内搜索…" aria-label="站内搜索…" autocomplete="off">
</div>

  </div>
</div>
</nav>
    </header>
    <div class="container-fluid td-outer">
      <div class="td-main">
        <div class="row flex-xl-nowrap">
          <aside class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none">
            <div id="td-sidebar-menu" class="td-sidebar__inner">
  <form class="td-sidebar__search d-flex align-items-center">
    <div class="td-search">
  <div class="td-search__icon"></div>
  <input type="search" class="td-search__input form-control td-search-input" placeholder="站内搜索…" aria-label="站内搜索…" autocomplete="off">
</div>

    <button class="btn btn-link td-sidebar__toggle d-md-none p-0 ms-3 fas fa-bars" type="button" data-bs-toggle="collapse" data-bs-target="#td-section-nav" aria-controls="td-section-nav" aria-expanded="false" aria-label="Toggle section navigation">
    </button>
  </form>
  <nav class="collapse td-sidebar-nav" id="td-section-nav">
    <div class="td-sidebar-nav__section nav-item dropdown d-block d-lg-none">
      <div class="dropdown">
  <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">中文</a>
  <ul class="dropdown-menu">
    <li><a class="dropdown-item" href="/no/"></a></li>
    </ul>
</div>
    </div>
    <ul class="td-sidebar-nav__section pe-md-3 ul-0">
      <li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child active-path" id="m-docs-li">
  <a href="/docs/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section tree-root" id="m-docs"><span class="">产品文档</span></a>
  <ul class="ul-1">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child active-path" id="m-docsintroduction-li">
  <a href="/docs/introduction/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docsintroduction"><span class="">产品介绍</span></a>
  <ul class="ul-2 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docsintroductionintro-and-scenario-li">
  <a href="/docs/introduction/intro-and-scenario/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docsintroductionintro-and-scenario"><span class="">简介与适用场景</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docsintroductionindustry-background-li">
  <a href="/docs/introduction/industry-background/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docsintroductionindustry-background"><span class="">行业背景</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child active-path" id="m-docsintroductionarchitecture-li">
  <a href="/docs/introduction/architecture/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docsintroductionarchitecture"><span class="">架构介绍</span></a>
  <ul class="ul-3 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child active-path" id="m-docsintroductionarchitecturearch-principle-li">
  <a href="/docs/introduction/architecture/arch-principle/" class="align-left ps-0 active td-sidebar-link td-sidebar-link__page" id="m-docsintroductionarchitecturearch-principle"><span class="td-sidebar-nav-active-item">架构原理</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docsintroductionarchitectureclass-delegation-principle-li">
  <a href="/docs/introduction/architecture/class-delegation-principle/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docsintroductionarchitectureclass-delegation-principle"><span class="">基座与模块间类委托加载原理介绍</span></a>
</li>
  </ul>
</li>
  </ul>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docsquick-start-li">
  <a href="/docs/quick-start/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docsquick-start"><span class="">快速开始</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docsvideo-training-li">
  <a href="/docs/video-training/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docsvideo-training"><span class="">视频教程</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docstutorials-li">
  <a href="/docs/tutorials/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docstutorials"><span class="">用户手册</span></a>
  <ul class="ul-2 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docstutorialsbase-create-li">
  <a href="/docs/tutorials/base-create/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docstutorialsbase-create"><span class="">基座接入</span></a>
  <ul class="ul-3 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsbase-createspringboot-and-sofaboot-li">
  <a href="/docs/tutorials/base-create/springboot-and-sofaboot/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsbase-createspringboot-and-sofaboot"><span class="">SpringBoot 或 SOFABoot 升级为基座</span></a>
</li>
  </ul>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docstutorialsmodule-create-li">
  <a href="/docs/tutorials/module-create/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docstutorialsmodule-create"><span class="">模块接入</span></a>
  <ul class="ul-3 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-createspringboot-and-sofaboot-li">
  <a href="/docs/tutorials/module-create/springboot-and-sofaboot/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-createspringboot-and-sofaboot"><span class="">SpringBoot 或 SOFABoot 一键升级为模块</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-createinit_by_archtype-li">
  <a href="/docs/tutorials/module-create/init_by_archtype/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-createinit_by_archtype"><span class="">使用 maven archtype 脚手架自动生成</span></a>
</li>
  </ul>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialstrial_step_by_step-li">
  <a href="/docs/tutorials/trial_step_by_step/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialstrial_step_by_step"><span class="">基座与模块并行开发验证</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docstutorialsmodule-development-li">
  <a href="/docs/tutorials/module-development/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docstutorialsmodule-development"><span class="">模块研发</span></a>
  <ul class="ul-3 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-developmentcoding-specification-li">
  <a href="/docs/tutorials/module-development/coding-specification/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-developmentcoding-specification"><span class="">编码规范</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-developmentmodule-slimming-li">
  <a href="/docs/tutorials/module-development/module-slimming/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-developmentmodule-slimming"><span class="">模块瘦身</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-developmentmodule-and-base-communication-li">
  <a href="/docs/tutorials/module-development/module-and-base-communication/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-developmentmodule-and-base-communication"><span class="">模块与模块、模块与基座通信</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-developmentmodule-dev-arkctl-li">
  <a href="/docs/tutorials/module-development/module-dev-arkctl/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-developmentmodule-dev-arkctl"><span class="">模块本地开发</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-developmentmodule-debug-li">
  <a href="/docs/tutorials/module-development/module-debug/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-developmentmodule-debug"><span class="">模块测试</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-developmentreuse-base-interceptor-li">
  <a href="/docs/tutorials/module-development/reuse-base-interceptor/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-developmentreuse-base-interceptor"><span class="">复用基座拦截器</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-developmentreuse-base-datasource-li">
  <a href="/docs/tutorials/module-development/reuse-base-datasource/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-developmentreuse-base-datasource"><span class="">复用基座数据源</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-developmentstatic-merge-deployment-li">
  <a href="/docs/tutorials/module-development/static-merge-deployment/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-developmentstatic-merge-deployment"><span class="">静态合并部署</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-developmentruntime-compatibility-list-li">
  <a href="/docs/tutorials/module-development/runtime-compatibility-list/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-developmentruntime-compatibility-list"><span class="">模块中官方支持的中间件客户端</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-developmentsofa-ark-li">
  <a href="/docs/tutorials/module-development/sofa-ark/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-developmentsofa-ark"><span class="">SOFAArk 关键用户文档</span></a>
</li>
  </ul>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docstutorialsmodule-operation-li">
  <a href="/docs/tutorials/module-operation/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docstutorialsmodule-operation"><span class="">模块运维</span></a>
  <ul class="ul-3 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-operationmodule-online-and-offline-li">
  <a href="/docs/tutorials/module-operation/module-online-and-offline/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-operationmodule-online-and-offline"><span class="">模块上线与下线</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-operationmodule-deployment-and-rollback-li">
  <a href="/docs/tutorials/module-operation/module-deployment-and-rollback/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-operationmodule-deployment-and-rollback"><span class="">模块发布</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-operationincompatible-base-and-module-upgrade-li">
  <a href="/docs/tutorials/module-operation/incompatible-base-and-module-upgrade/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-operationincompatible-base-and-module-upgrade"><span class="">基座和模块不兼容发布</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-operationmodule-scale-and-replace-li">
  <a href="/docs/tutorials/module-operation/module-scale-and-replace/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-operationmodule-scale-and-replace"><span class="">模块扩缩容与替换</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-operationoperation-and-scheduling-strategy-li">
  <a href="/docs/tutorials/module-operation/operation-and-scheduling-strategy/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-operationoperation-and-scheduling-strategy"><span class="">模块发布运维策略</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-operationarklet-standalone-usage-li">
  <a href="/docs/tutorials/module-operation/arklet-standalone-usage/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-operationarklet-standalone-usage"><span class="">独立使用 Arklet</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-operationmodule-information-viewing-li">
  <a href="/docs/tutorials/module-operation/module-information-viewing/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-operationmodule-information-viewing"><span class="">模块信息查看</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-operationmodule-service-li">
  <a href="/docs/tutorials/module-operation/module-service/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-operationmodule-service"><span class="">模块Service</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docstutorialsmodule-operationcrd-definition-li">
  <a href="/docs/tutorials/module-operation/crd-definition/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docstutorialsmodule-operationcrd-definition"><span class="">所有 K8S 资源定义及部署方式</span></a>
</li>
  </ul>
</li>
  </ul>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docscontribution-guidelines-li">
  <a href="/docs/contribution-guidelines/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docscontribution-guidelines"><span class="">参与社区</span></a>
  <ul class="ul-2 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesour-vision-li">
  <a href="/docs/contribution-guidelines/our-vision/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesour-vision"><span class="">开放包容理念</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinescommunication-channel-li">
  <a href="/docs/contribution-guidelines/communication-channel/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinescommunication-channel"><span class="">交流渠道</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docscontribution-guidelinescontribution-li">
  <a href="/docs/contribution-guidelines/contribution/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docscontribution-guidelinescontribution"><span class="">贡献社区</span></a>
  <ul class="ul-3 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinescontributionlocal-dev-test-li">
  <a href="/docs/contribution-guidelines/contribution/local-dev-test/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinescontributionlocal-dev-test"><span class="">本地开发测试</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinescontributionfirst-pr-li">
  <a href="/docs/contribution-guidelines/contribution/first-pr/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinescontributionfirst-pr"><span class="">完成第一次 PR 提交</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinescontributionimprove-doc-and-process-and-issue-li">
  <a href="/docs/contribution-guidelines/contribution/improve-doc-and-process-and-issue/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinescontributionimprove-doc-and-process-and-issue"><span class="">文档、Issue、流程贡献</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinescontributionsermon-li">
  <a href="/docs/contribution-guidelines/contribution/sermon/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinescontributionsermon"><span class="">组织会议和运营布道</span></a>
</li>
  </ul>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesrole-and-promotion-li">
  <a href="/docs/contribution-guidelines/role-and-promotion/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesrole-and-promotion"><span class="">社区角色与晋升</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinessofa-ark-li">
  <a href="/docs/contribution-guidelines/sofa-ark/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docscontribution-guidelinessofa-ark"><span class="">SOFAArk 技术文档</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docscontribution-guidelinesarklet-li">
  <a href="/docs/contribution-guidelines/arklet/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docscontribution-guidelinesarklet"><span class="">Arklet 技术文档</span></a>
  <ul class="ul-3 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesarkletarchitecture-li">
  <a href="/docs/contribution-guidelines/arklet/architecture/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesarkletarchitecture"><span class="">Arklet 架构设计与接口设计</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesarklethow-to-release-li">
  <a href="/docs/contribution-guidelines/arklet/how-to-release/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesarklethow-to-release"><span class="">如何发布 Arklet 版本</span></a>
</li>
  </ul>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docscontribution-guidelinesmodule-controller-li">
  <a href="/docs/contribution-guidelines/module-controller/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docscontribution-guidelinesmodule-controller"><span class="">ModuleController 技术文档</span></a>
  <ul class="ul-3 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesmodule-controllerarchitecture-li">
  <a href="/docs/contribution-guidelines/module-controller/architecture/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesmodule-controllerarchitecture"><span class="">ModuleController 架构设计</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesmodule-controllercrd-definition-li">
  <a href="/docs/contribution-guidelines/module-controller/crd-definition/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesmodule-controllercrd-definition"><span class="">CRD 模型设计</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesmodule-controllercore-code-structure-li">
  <a href="/docs/contribution-guidelines/module-controller/core-code-structure/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesmodule-controllercore-code-structure"><span class="">核心代码结构</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesmodule-controllermodule-lifecycle-li">
  <a href="/docs/contribution-guidelines/module-controller/module-lifecycle/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesmodule-controllermodule-lifecycle"><span class="">模块生命周期</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesmodule-controllersequence-diagram-li">
  <a href="/docs/contribution-guidelines/module-controller/sequence-diagram/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesmodule-controllersequence-diagram"><span class="">核心流程时序图</span></a>
</li>
  </ul>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docscontribution-guidelinesarkctl-li">
  <a href="/docs/contribution-guidelines/arkctl/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docscontribution-guidelinesarkctl"><span class="">Arkctl 技术文档</span></a>
  <ul class="ul-3 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesarkctlarchitecture-li">
  <a href="/docs/contribution-guidelines/arkctl/architecture/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesarkctlarchitecture"><span class="">Arkctl 技术文档</span></a>
</li>
  </ul>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docscontribution-guidelinesruntime-li">
  <a href="/docs/contribution-guidelines/runtime/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docscontribution-guidelinesruntime"><span class="">多模块运行时适配或最佳实践</span></a>
  <ul class="ul-3 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesruntimelogj42-li">
  <a href="/docs/contribution-guidelines/runtime/logj42/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesruntimelogj42"><span class="">log4j2 的多模块化适配</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docscontribution-guidelinesruntimeehcache-li">
  <a href="/docs/contribution-guidelines/runtime/ehcache/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docscontribution-guidelinesruntimeehcache"><span class="">ehcache 的多模块化最佳实践</span></a>
</li>
  </ul>
</li>
  </ul>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id="m-docsfaq-li">
  <a href="/docs/faq/" class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id="m-docsfaq"><span class="">常见 FAQ</span></a>
  <ul class="ul-2 foldable">
    <li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docsfaqfaq-li">
  <a href="/docs/faq/faq/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docsfaqfaq"><span class="">常见问题列表</span></a>
</li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id="m-docsfaqimport-full-springboot-in-module-li">
  <a href="/docs/faq/import-full-springboot-in-module/" class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id="m-docsfaqimport-full-springboot-in-module"><span class="">如果模块独立引入 SpringBoot 框架部分会怎样？</span></a>
</li>
  </ul>
</li>
  </ul>
</li>
    </ul>
  </nav>
</div>

          </aside>
          <aside class="d-none d-xl-block col-xl-2 td-sidebar-toc d-print-none">
            
<div class="td-page-meta ms-2 pb-1 pt-2 mb-0">
<a href="https://github.com/sofastack/sofa-serverless/tree/master/docs/content/zh-cn/docs/introduction/architecture/arch-principle.md" class="td-page-meta--view" target="_blank" rel="noopener"><i class="fa-solid fa-file-lines fa-fw"></i> 查看页面源码</a>
  <a href="https://github.com/sofastack/sofa-serverless/edit/master/docs/content/zh-cn/docs/introduction/architecture/arch-principle.md" class="td-page-meta--edit" target="_blank" rel="noopener"><i class="fa-solid fa-pen-to-square fa-fw"></i> 编辑此页</a>
  <a href="https://github.com/sofastack/sofa-serverless/new/master/docs/content/zh-cn/docs/introduction/architecture/arch-principle.md?filename=change-me.md&amp;value=---%0Atitle%3A&#43;%22Long&#43;Page&#43;Title%22%0AlinkTitle%3A&#43;%22Short&#43;Nav&#43;Title%22%0Aweight%3A&#43;100%0Adescription%3A&#43;%3E-%0A&#43;&#43;&#43;&#43;&#43;Page&#43;description&#43;for&#43;heading&#43;and&#43;indexes.%0A---%0A%0A%23%23&#43;Heading%0A%0AEdit&#43;this&#43;template&#43;to&#43;create&#43;your&#43;new&#43;page.%0A%0A%2A&#43;Give&#43;it&#43;a&#43;good&#43;name%2C&#43;ending&#43;in&#43;%60.md%60&#43;-&#43;e.g.&#43;%60getting-started.md%60%0A%2A&#43;Edit&#43;the&#43;%22front&#43;matter%22&#43;section&#43;at&#43;the&#43;top&#43;of&#43;the&#43;page&#43;%28weight&#43;controls&#43;how&#43;its&#43;ordered&#43;amongst&#43;other&#43;pages&#43;in&#43;the&#43;same&#43;directory%3B&#43;lowest&#43;number&#43;first%29.%0A%2A&#43;Add&#43;a&#43;good&#43;commit&#43;message&#43;at&#43;the&#43;bottom&#43;of&#43;the&#43;page&#43;%28%3C80&#43;characters%3B&#43;use&#43;the&#43;extended&#43;description&#43;field&#43;for&#43;more&#43;detail%29.%0A%2A&#43;Create&#43;a&#43;new&#43;branch&#43;so&#43;you&#43;can&#43;preview&#43;your&#43;new&#43;file&#43;and&#43;request&#43;a&#43;review&#43;via&#43;Pull&#43;Request.%0A" class="td-page-meta--child" target="_blank" rel="noopener"><i class="fa-solid fa-pen-to-square fa-fw"></i> 添加子页面</a>
  <a href="https://github.com/sofastack/sofa-serverless/issues/new?title=%e6%9e%b6%e6%9e%84%e5%8e%9f%e7%90%86" class="td-page-meta--issue" target="_blank" rel="noopener"><i class="fa-solid fa-list-check fa-fw"></i> 提交文档问题</a>
  <a id="print" href="/docs/introduction/architecture/_print/"><i class="fa-solid fa-print fa-fw"></i> 整节打印</a>

</div>

            <div class="td-toc">
        <nav id="TableOfContents">
  <ul>
    <li><a href="#模块化应用架构">模块化应用架构</a>
      <ul>
        <li><a href="#模块的定义">模块的定义</a></li>
        <li><a href="#模块的隔离与共享">模块的隔离与共享</a></li>
        <li><a href="#模块间通信">模块间通信</a></li>
        <li><a href="#模块的可演进">模块的可演进</a></li>
        <li><a href="#模块化架构的优势">模块化架构的优势</a></li>
      </ul>
    </li>
    <li><a href="#平台架构">平台架构</a></li>
  </ul>
</nav>
      </div>
    
            

          </aside>
          <main class="col-12 col-md-9 col-xl-8 ps-md-5" role="main">
            
  

            
            
<div class="td-content">
	<h1>架构原理</h1>
	
	<header class="article-meta">
		
</header>
	<h2 id="模块化应用架构">模块化应用架构</h2>
<p>为了解决这些问题，我们对应用同时做了横向和纵向的拆分。首先第一步纵向拆分：把应用拆分成<strong>基座</strong>和<strong>业务</strong>两层，这两层分别对应两层的组织分工。基座小组与传统应用一样，负责机器维护、通用逻辑沉淀、业务架构治理，并为业务提供运行资源和环境。通过关注点分离的方式为业务屏蔽业务以下所有基础设施，聚焦在业务自身上。第二部我们将业务进行横向切分出多个模块，多个模块之间独立并行迭代互不影响，同时模块由于不包含基座部分，构建产物非常轻量，启动逻辑也只包含业务本身，所以启动快，具备秒级的验证能力，让模块开发得到极致的提效。<br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695131313965-18385213-eded-4a6b-b554-db5312fa2c9d.png#clientId=ua84a92a5-30aa-4&amp;from=paste&amp;height=431&amp;id=udb6b29d5&amp;originHeight=862&amp;originWidth=3448&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=192627&amp;status=done&amp;style=none&amp;taskId=u9a114a24-0887-48d9-87b2-57d3e15eb80&amp;title=&amp;width=1724" alt="image.png"><br />拆分之前，每个开发者可能感知从框架到中间件到业务公共部分到业务自身所有代码和逻辑，拆分后，团队的协作分工也从发生改变，研发人员分工出两种角色，基座和模块开发者，模块开发者不关系资源与容量，享受秒级部署验证能力，聚焦在业务逻辑自身上。<br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695131554610-ef5c4a2f-0080-45eb-8fed-55fdf5d827f9.png#clientId=ua84a92a5-30aa-4&amp;from=paste&amp;height=459&amp;id=u7227f759&amp;originHeight=918&amp;originWidth=3714&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=309179&amp;status=done&amp;style=none&amp;taskId=u12307968-2a79-4f77-9c78-e976399c60e&amp;title=&amp;width=1857" alt="image.png"></p>
<p>这里要重点看下我们是如何做这些纵向和横向切分的，切分是为了隔离，隔离是为了能够独立迭代、剥离不必要的依赖，然而如果只是隔离是没有共享相当于只是换了个部署的位置而已，很难有好的效果。所以我们除了隔离还有共享能力，所以这里需要聚焦在隔离与共享上来理解模块化架构背后的原理。</p>
<h3 id="模块的定义">模块的定义</h3>
<p>在这之前先看下这里的模块是什么？模块是通过原来应用减去基座部分得到的，这里的减法是通过设置模块里依赖的 scope 为 provided 实现的，<br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695132446404-0571be28-5cdf-452e-90f5-001a4209c750.png#clientId=u177778f7-e9cd-4&amp;from=paste&amp;height=142&amp;id=ud796498d&amp;originHeight=516&amp;originWidth=1834&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=108247&amp;status=done&amp;style=none&amp;taskId=u8201db6e-cf5e-4fbd-ab24-6a0223e1709&amp;title=&amp;width=506" alt="image.png"><br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695132481921-6fb1c3da-0de3-46ce-bf8e-cc645f63157c.png#clientId=u177778f7-e9cd-4&amp;from=paste&amp;height=187&amp;id=u31cba15e&amp;originHeight=524&amp;originWidth=1026&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=205261&amp;status=done&amp;style=none&amp;taskId=u2c981d7a-dfff-43c6-b6c6-5c6a5701d2b&amp;title=&amp;width=367" alt="image.png"><br />一个模块可以由这三点定义：</p>
<ol>
<li>SpringBoot 打包生成的 jar 包</li>
<li>一个模块： 一个 SpringContext + 一个 ClassLoader</li>
<li>热部署（升级的时候不需要启动进程）</li>
</ol>
<h3 id="模块的隔离与共享">模块的隔离与共享</h3>
<p>模块通过 ClassLoader 隔离配置和代码，SpringContext 隔离 Bean 和服务，可以通过调用 Spring ApplicationContext 的start close 方法来动态启动和关闭服务。通过 SOFAArk 来共享模块和基座的配置和代码 Class，通过 SpringContext Manager 来共享多模块间的 Bean 和服务。<br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695132610081-3efe470f-5c65-4d46-b4e4-1ecb15c8d789.png#clientId=u771aab18-101c-4&amp;from=paste&amp;height=313&amp;id=u4c63a679&amp;originHeight=972&amp;originWidth=1334&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=160772&amp;status=done&amp;style=none&amp;taskId=uafe9a1eb-025c-4e1e-9316-35b8bd32b96&amp;title=&amp;width=429" alt="image.png"><br />并且在 JVM 内通过</p>
<ol>
<li>Ark Container 提供多 ClassLoader 运行环境</li>
<li>Arklet 来管理模块生命周期</li>
<li>Framework Adapter 将 SpringBoot 生命周期与模块生命周期关联起来</li>
<li>SOFAArk 默认委托加载机制，打通模块与基座类委托加载</li>
<li>SpringContext Manager 提供 Bean 与服务发现调用机制</li>
<li>基座本质也是模块，拥有独立的 SpringContext 和 ClassLoader</li>
</ol>
<p><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695139080634-1669ea76-c486-47fc-ac4f-5900833896b9.png#clientId=u71a0730f-fb54-4&amp;from=paste&amp;height=275&amp;id=u1cf30803&amp;originHeight=722&amp;originWidth=1428&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=198221&amp;status=done&amp;style=none&amp;taskId=u88cd7c27-4850-4b02-9c6f-504b4456a94&amp;title=&amp;width=544" alt="image.png"></p>
<p>但是在 Java 领域模块化技术已经发展了20年了，为什么这里的模块化技术能够在蚂蚁内部规模化落地，这里的核心原因是<br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695139240123-37a5b5e7-38ee-4b33-b84b-4d58e8b9f371.png#clientId=u71a0730f-fb54-4&amp;from=paste&amp;height=596&amp;id=u7b5e0183&amp;originHeight=1192&amp;originWidth=2954&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=587199&amp;status=done&amp;style=none&amp;taskId=uc2ceea08-092e-4bfd-9566-d97ab3d3b74&amp;title=&amp;width=1477" alt="image.png"><br />基于 SOFAArk 和 SpringContext Manager 的多模块能力，提供了低成本的使用方式。</p>
<h4 id="隔离方面">隔离方面</h4>
<p>对于其他的模块化技术，从隔离角度来看，JPMS 和 Spring Modulith 的隔离是通过自定义的规则来做限制的，Spring Modulith 还需要在单元测试里执行 verify 来做校验，隔离能力比较弱且一定程度上是比较 tricky 的，对于存量应用使用来说也是有不小改造成本的，甚至说是存量应用无法改造。而 SOFAArk 和 OSGI 一样采用 ClassLoader 和 SpringContext 的方式进行配置与代码、bean与服务的隔离，对原生应用的启动模式完全保持一致。</p>
<h4 id="共享方面">共享方面</h4>
<p>SOFAArk 的隔离方式和 OSGI 是一致的，但是在共享方面 OSGI 和 JPMS、Spring Modulith 一样都需要在源模块和目标模块间定义导入导出列表或其他配置，这造成业务使用模块需要强感知和理解多模块的技术，使用成本是比较高的，而 SOFAArk 则定义了默认的类委托加载机制，和跨模块的 Bean 和服务发现机制，让业务不用改造的情况下能够使用多模块的能力。<br />这里额外提下，为什么基于 SOFAArk 的多模块化技术能提供这些默认的能力，而做到低成本的使用呢？这里主要的原因是因为我们对模块做了角色的区分，区分出了基座与模块，在这个核心原因基础上也对低成本使用这块比较重视，做了重要的设计考量和取舍。具体有哪些设计和取舍，可以查看技术实现文章。</p>
<h3 id="模块间通信">模块间通信</h3>
<p>模块间通信主要依托 SpringContext Manager 的 Bean 与服务发现调用机制提供基础能力，<br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695171905613-2546f555-ff25-4a58-81aa-02d77bfb2b1d.png#clientId=ud7a2066a-ba29-4&amp;from=paste&amp;height=307&amp;id=uc8826222&amp;originHeight=724&amp;originWidth=1048&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=202275&amp;status=done&amp;style=none&amp;taskId=u537670c5-c728-487a-9710-80986ce8532&amp;title=&amp;width=444" alt="image.png"></p>
<h3 id="模块的可演进">模块的可演进</h3>
<p>回顾背景里提到的几大问题，可以看到通过模块化架构的隔离与共享能力，可以解决掉基础设施复杂、多人协作阻塞、资源与长期维护成本高的问题，但还有微服务拆分与业务敏捷度不一致的问题未解决。<br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695175219841-965cd163-a4bd-4cd0-b828-c620b29c0ffc.png#clientId=uaaa65411-0843-4&amp;from=paste&amp;height=185&amp;id=ua68375b7&amp;originHeight=894&amp;originWidth=2906&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=417377&amp;status=done&amp;style=none&amp;taskId=ud94c9602-7cd1-4bcb-8654-39fe8938d37&amp;title=&amp;width=602" alt="image.png"><br />在这里我们通过降低微服务拆分的成本来解决，那么怎么降低微服务拆分成本呢？这里主要是在单体架构和微服务架构之间增加模块化架构</p>
<ol>
<li>模块不占资源所以拆分没有资源成本</li>
<li>模块不包含业务公共部分和框架、中间件部分，所以模块没有长期的 sdk 升级维护成本</li>
<li>模块自身也是 SpringBoot，我们提供工具辅助单体应用低成本拆分成模块应用</li>
<li>模块具备灵活部署能力，可以合并部署在一个 JVM 内，也可拆除独立部署，这样模块可以按需低成本演进成微服务或回退会单体应用模式</li>
</ol>
<p><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695175141130-d3b55e17-70c3-4e7c-aeef-2e071f89ada8.png#clientId=uaaa65411-0843-4&amp;from=paste&amp;height=316&amp;id=u589ef06e&amp;originHeight=632&amp;originWidth=3642&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=139102&amp;status=done&amp;style=none&amp;taskId=uf9f96d68-7456-4af5-951e-d9351092988&amp;title=&amp;width=1821" alt="image.png"><br />图中的箭头是双向的，如果当前微服务拆分过多，也可以将多个微服务低成本改造成模块合并部署在一个 JVM 内。所以这里的本质是通过在单体架构和微服务架构之间增加一个可以双向过渡的模块化架构，降低改造成本的同时，也让开发者可以根据业务发展按需演进或回退。这样可以把微服务的这几个问题解决掉</p>
<h3 id="模块化架构的优势">模块化架构的优势</h3>
<p>模块化架构的优势主要集中在这四点：快、省、灵活部署、可演进，<br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695180240688-82520d0c-2304-47dc-a9f3-22af08424100.png#clientId=ueb39d37f-ca7b-4&amp;from=paste&amp;height=237&amp;id=u4c60feb3&amp;originHeight=688&amp;originWidth=1504&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=437668&amp;status=done&amp;style=none&amp;taskId=uf04ead3d-7cf7-41e7-bfff-81857bf5918&amp;title=&amp;width=518" alt="image.png"></p>
<p>与传统应用对比数据如下，可以看到在研发阶段、部署阶段、运行阶段都得到了10倍以上的提升效果。<br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695180250909-f5eca1b3-c416-4bac-9732-549a9bed8b87.png#clientId=ueb39d37f-ca7b-4&amp;from=paste&amp;height=261&amp;id=u8907b613&amp;originHeight=522&amp;originWidth=2838&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=219589&amp;status=done&amp;style=none&amp;taskId=ua4b2bd1b-a75f-4945-abce-68826a43377&amp;title=&amp;width=1419" alt="image.png"></p>
<h2 id="平台架构">平台架构</h2>
<p>只有应用架构还不够，需要从研发阶段到运维阶段到运行阶段都提供完整的配套能力，才能让模块化应用架构的优势真正触达到研发人员。<br /><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695182073971-12b14861-b6fa-470c-a140-737d40ff0b3e.png#clientId=u9014394b-3a6a-4&amp;from=paste&amp;height=192&amp;id=ub53430b2&amp;originHeight=384&amp;originWidth=1720&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=79335&amp;status=done&amp;style=none&amp;taskId=u1eb2a897-c2ca-437f-8d56-7067be175e2&amp;title=&amp;width=860" alt="image.png"><br />在研发阶段，需要提供基座接入能力，模块创建能力，更重要的是模块的本地快速构建与联调能力；在运维阶段，提供快速的模块发布能力，在模块发布基础上提供 A/B 测试和秒级扩缩容能力；在运行阶段，提供模块的可靠性能力，模块可观测、流量精细化控制、调度和伸缩能力。</p>
<p><img src="https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695182125970-f9529014-0386-4922-b8eb-5d0c82a7e5d8.png#clientId=u9014394b-3a6a-4&amp;from=paste&amp;height=370&amp;id=uf365ffd8&amp;originHeight=740&amp;originWidth=2096&amp;originalType=binary&amp;ratio=2&amp;rotation=0&amp;showTitle=false&amp;size=242246&amp;status=done&amp;style=none&amp;taskId=uf07de18d-931e-4ffd-9540-d4be10de3e7&amp;title=&amp;width=1048" alt="image.png"><br />组件视图</p>
<p>在整个平台里，需要四个组件：</p>
<ol>
<li>研发工具 Arkctl, 提供模块创建、快速联调测试等能力</li>
<li>运行组件 SOFAArk, Arklet，提供模块运维、模块生命周期管理，多模块运行环境</li>
<li>控制面组件 ModuleController
<ol>
<li>ModuleDeployment 提供模块发布与运维能力</li>
<li>ModuleScheduler 提供模块调度能力</li>
<li>ModuleScaler 提供模块伸缩能力</li>
</ol>
</li>
</ol>
<br/>

	<style>
  .feedback--answer {
    display: inline-block;
  }
  .feedback--answer-no {
    margin-left: 1em;
  }
  .feedback--response {
    display: none;
    margin-top: 1em;
  }
  .feedback--response__visible {
    display: block;
  }
</style>
<div class="d-print-none">
<h2 class="feedback--title">Feedback</h2>
<p class="feedback--question">Was this page helpful?</p>
<button class="btn btn-primary mb-4 feedback--answer feedback--answer-yes">Yes</button>
<button class="btn btn-primary mb-4 feedback--answer feedback--answer-no">No</button>
<p class="feedback--response feedback--response-yes">
  很高兴文档对您有帮助! 欢迎<a href="https://github.com/sofastack/sofa-serverless/issues/new?assignees=&labels=&projects=&template=feature_request.md">为社区提建议</a>。
</p>
<p class="feedback--response feedback--response-no">
  很抱歉文档对您没帮助。邀请您<a href="https://github.com/sofastack/sofa-serverless/issues/new?assignees=&labels=&projects=&template=feature_request.md">为文档提建议</a>或者<a href="https://github.com/sofastack/sofa-serverless/tree/master/user-docs/content/zh-cn">直接完善该文档</a>。
</p>
</div>
<script>
  const yesButton = document.querySelector('.feedback--answer-yes');
  const noButton = document.querySelector('.feedback--answer-no');
  const yesResponse = document.querySelector('.feedback--response-yes');
  const noResponse = document.querySelector('.feedback--response-no');
  const disableButtons = () => {
    yesButton.disabled = true;
    noButton.disabled = true;
  };
  const sendFeedback = (value) => {
    if (typeof ga !== 'function') return;
    const args = {
      command: 'send',
      hitType: 'event',
      category: 'Helpful',
      action: 'click',
      label: window.location.pathname,
      value: value
    };
    ga(args.command, args.hitType, args.category, args.action, args.label, args.value);
  };
  yesButton.addEventListener('click', () => {
    yesResponse.classList.add('feedback--response__visible');
    disableButtons();
    sendFeedback(1);
  });
  noButton.addEventListener('click', () => {
    noResponse.classList.add('feedback--response__visible');
    disableButtons();
    sendFeedback(0);
  });
</script>

		<br />
	<div class="text-muted mt-5 pt-3 border-top">
  最后修改 October 26, 2023: <a href="https://github.com/sofastack/sofa-serverless/commit/6b8065064cb1c7b8414fd9b2111283f8da0136f0">add styles (6b806506)</a>
</div>

</div>


          </main>
        </div>
      </div>
      <footer class="td-footer row d-print-none">
  <div class="container-fluid">
    <div class="row mx-md-2">
      <div class="col-6 col-sm-4 text-xs-center order-sm-2">
        
        
        
<ul class="td-footer__links-list">
  
  <li class="td-footer__links-item" data-bs-toggle="tooltip" title="通过社区交流群" aria-label="通过社区交流群">
    <a target="_blank" rel="noopener" href="/docs/contribution-guidelines/communication-channel/" aria-label="通过社区交流群">
      <i class="fab fa-twitter"></i>
    </a>
  </li>
  
</ul>

        
        
      </div>
      <div class="col-6 col-sm-4 text-end text-xs-center order-sm-3">
        
        
        
<ul class="td-footer__links-list">
  
  <li class="td-footer__links-item" data-bs-toggle="tooltip" title="看这里" aria-label="看这里">
    <a target="_blank" rel="noopener" href="/docs/contribution-guidelines/contribution/first-pr/" aria-label="看这里">
      <i class="fab fa-github"></i>
    </a>
  </li>
  
</ul>

        
        
      </div>
      <div class="td-footer__copyright-etc col-12 col-sm-4 text-center py-2 order-sm-2">
        <span>&copy; 2023 SOFAServerless 开源社区 保留所有权利</span>
        
        
      </div>
    </div>
  </div>
</footer>
    </div>
    
  <script src="/js/main.min.1eb4262674b2d02aa8d18559fef13b166dbdfa627fd0a495c66e11577c026aa3.js" integrity="sha256-HrQmJnSy0Cqo0YVZ/vE7Fm29&#43;mJ/0KSVxm4RV3wCaqM=" crossorigin="anonymous"></script>
<script src='/js/prism.js'></script>
<script src='/js/tabpane-persist.js'></script>

  </body>
</html>